//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.chris.impl;

import com.chris.entity.menu;
import com.chris.utils.DbConnection;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

public class menuImpl {
    private final QueryRunner runner = new QueryRunner();

    public menuImpl() {
    }

    public List<menu> search(String params, String args) throws SQLException {
        String sql = "select * from menu where " + params + " like '%" + args + "%'";
        Connection connection = DbConnection.getConnection();
        return this.runner.query(connection, sql, new BeanListHandler<>(menu.class));
    }

    public void insert(String journal_title, String cn, String issn, String public_cycle, String public_area, String sponsor) throws SQLException {
        String sql = "insert into menu (journal_title,cn,issn,public_cycle,public_area,sponsor)values(?,?,?,?,?,?) ";
        Connection connection = DbConnection.getConnection();
        this.runner.execute(connection, sql, journal_title, cn, issn, public_area, public_cycle, sponsor);
    }
    public List<menu>get10() throws SQLException {
        String sql = "select * from menu limit 10";
        Connection connection = DbConnection.getConnection();
        return runner.query(connection,sql,new BeanListHandler<>(menu.class));
    }
    public List<menu> getAll()throws SQLException {
        String sql = "select * from menu";
        Connection connection = DbConnection.getConnection();
        return runner.query(connection,sql,new BeanListHandler<>(menu.class));
    }
}
